class HousingApplicationController < ApplicationController
  
  layout 'two_column'
  
  verify :method => :post, :only => [ :submit ], :redirect_to => { :action => :index }
  
  def index
    @questions = AppQuestion.find(:all, :order => :position)
  end

  def submit
    
    @questions = AppQuestion.find(:all, :order => :position)
    @valid = true
    @questions.each do |q|
      if params[:application]["#{q.id}"] == "" && q.required
        @valid = false
        # This fields should not be empty, do something
      end
    end
    
    HousingMailer.deliver_application(params[:application]) if @valid
  end
end
